﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Collections;
using System.IO;
using System.Windows.Forms;

namespace PokemonRuby
{
    public class GameCharacter
    {
        public List<Image> lstImg = new List<Image>();
        public int movingStatus = 0;
        public int movingDirection = 0;
        public int x = 0;
        public int y = 0;
        public int z = 0;
        public Hashtable htGameCharacter = new Hashtable();
        public ArrayList arrPokemon = new ArrayList();
        protected string appPath = null;

        public void LoadResourceCharacter()
        {
            this.htGameCharacter.Clear();
            FileInfo fi = new FileInfo(Application.ExecutablePath);
            this.appPath = fi.Directory.FullName;

            string path = Path.Combine(this.appPath, "CharacterImages");
            path = Path.Combine(this.appPath, "CharacterImages");
            string[] sar = Directory.GetFiles(path, "*.png");
            for (int i = 0; i < sar.Length; i++)
            {
                string fileName = sar[i];
                fi = new FileInfo(fileName);

                string key = fi.Name;
                key = key.Substring(0, key.Length - 4);
                key = key.ToLower().Trim();

                Image im = Image.FromFile(fileName);
                this.htGameCharacter.Add(int.Parse(key), im);
            }
        }
        public GameCharacter LoadGameCharacter()
        {
            GameCharacter character1 = new GameCharacter();
            character1.lstImg.Add((Image)htGameCharacter[1]);
            character1.lstImg.Add((Image)htGameCharacter[2]);
            character1.lstImg.Add((Image)htGameCharacter[3]);
            character1.lstImg.Add((Image)htGameCharacter[4]);
            character1.lstImg.Add((Image)htGameCharacter[5]);
            character1.lstImg.Add((Image)htGameCharacter[6]);
            character1.lstImg.Add((Image)htGameCharacter[7]);
            character1.lstImg.Add((Image)htGameCharacter[8]);
            character1.lstImg.Add((Image)htGameCharacter[9]);
            character1.lstImg.Add((Image)htGameCharacter[10]);
            character1.lstImg.Add((Image)htGameCharacter[11]);
            character1.lstImg.Add((Image)htGameCharacter[12]);
            character1.x = 8;
            character1.y = 8;
            character1.z = 0;
            Pokemon pkm = new Pokemon();
            pkm.Name = "Pikachu";
            pkm.getPropertiesOfCharacter("Pikachu");
            pkm.LoadLoaiVoCong("Pikachu");
            arrPokemon.Add(pkm);
            return character1;
        }
    }
}
